package com.bjtu.literatureclient.util.create;

import com.bjtu.literatureclient.domain.Author;

import java.util.List;


public class JournalPapersCreate {

	Creates creates = new Creates();

	/**
	 * 生成英文期刊析出论文参考文献条目
	 * 
	 * @param authors
	 * @param title
	 * @param journalName
	 * @param volume
	 * @param num
	 * @param year
	 * @param startPage
	 * @param endPage
	 * @return</br>
	 * 
	 * @time: 2012/2012-5-6/上午10:25:07
	 */
	public String CreateItem1(List<Author> authors, String title,
							  String journalName, String volume, String num, String year,
							  String startPage, String endPage) {
		String item = "";
		String lastName;
		String middleName;
		String firstNameName;
		for (int i = 0; i < authors.size() - 1; i++) {
			Author author = authors.get(i);
			lastName = author.getLastName();
			middleName = author.getMiddleName();
			firstNameName = author.getFirstName();

			// 中间名不存在
			if (middleName.equals("")) {
				item += creates.toUpperCaseFirstLetter(lastName) + ", "
						+ creates.getFirstLetter(firstNameName) + "., ";
			} else {
				item += creates.toUpperCaseFirstLetter(lastName) + ", "
						+ creates.getFirstLetter(middleName) + ". "
						+ creates.getFirstLetter(firstNameName) + "., ";
			}
		}

		// 最后以为作者
		lastName = authors.get(authors.size() - 1).getLastName();
		middleName = authors.get(authors.size() - 1).getMiddleName();
		firstNameName = authors.get(authors.size() - 1).getFirstName();

		// 中间名不存在
		if (middleName.equals("")) {
			item += creates.toUpperCaseFirstLetter(lastName) + ", "
					+ creates.getFirstLetter(firstNameName) + ".. ";
		} else {
			item += creates.toUpperCaseFirstLetter(lastName) + ", "
					+ creates.getFirstLetter(middleName) + ". "
					+ creates.getFirstLetter(firstNameName) + ".. ";
		}

		item += year + ". ";
		item += title + "[J]. ";
		item += journalName + " " + volume + "(" + num + ")" + ":" + startPage
				+ "-" + endPage + ". ";

		return item;
	}

}

